﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Application.GatewayApp.Dto.Output
{
    /// <summary>
    /// 银行卡信息输出
    /// </summary>
    public class BankCardOutput
    {
        /// <summary>
        /// 付款Id
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 银行代码
        /// </summary>
        public string BankNo { get; set; }

        /// <summary>
        /// 银行名称
        /// </summary>
        public string BankName { get; set; }

        /// <summary>
        /// 银行LogoUrl
        /// </summary>
        public string BankLogoUrl { get; set; }

        private string _MobilePhone;

        /// <summary>
        /// 手机号
        /// </summary>
        public string MobilePhone
        {
            get
            {
                return this._MobilePhone;
            }
            set
            {
                _MobilePhone = SecurityMobilePhone(value);
            }
        }

        /// <summary>
        /// 通道Id
        /// </summary>
        public string ChannelId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mobilePhone"></param>
        /// <returns></returns>
        public static string SecurityMobilePhone(string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return "";
            }
            if (value.Length > 4)
            {
                return string.Format("{0}****{1}", value.Substring(0, 3), value.Substring(value.Length - 4));
            }
            else
            {
                return "****";
            }
        }

        private string _CardLastNo;

        /// <summary>
        /// 卡尾号
        /// </summary>
        public string CardLastNo
        {
            get
            {
                return _CardLastNo;
            }
            set
            {
                if (value != null && value.Length > 4)
                {
                    _CardLastNo = value.Substring(value.Length - 4);
                }
                else
                {
                    _CardLastNo = value;
                }
            }
        }

        /// <summary>
        /// 卡类型
        /// </summary>
        public int CardType { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public int State { get; set; }
    }
}
